<?php
/**
 * Pager
 * 
 * 作者:  姚刚 (yaogang@the9sense.com)
 * 创建时间: 2011-03-31 02:06:00
 * 修改记录: 
 * 
 * $Id: Pager.php 18 2011-04-17 12:50:07Z coosuu $
 */

class Pager {

    public static function convert($pageOptions) {

        if (!$pageOptions['perPage']) {
            $pageOptions['perPage'] = 15;
        }

        $pageOptions['pages'] = ceil($pageOptions['totalItems'] / $pageOptions['perPage']);

        if ($pageOptions['currentPage'] <= 0) {
            $pageOptions['currentPage'] = 1;
        }

        if ($pageOptions['currentPage'] >= $pageOptions['pages']) {
            $pageOptions['currentPage'] = $pageOptions['pages'];
        }

        return $pageOptions;
    }
}
